package com.expdatacloud.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author jie
 * @date 2019/10/28 -14:55
 */
@RestController
public class DemoController {


    /**
     * 当这个方法的入参改变的时候，为所有的方法增加String library入参
     */
    @GetMapping("/environment/{library}")
    public String environment(@PathVariable String library, HttpServletResponse response, HttpServletRequest request) {
        Cookie cookie = new Cookie("library", library);
        cookie.setPath("/");
        response.addCookie(cookie);
        return "数据源切换为"+library;
    }

}
